﻿using Microsoft.Extensions.Logging;

namespace _03_Logging.Extensions.File
{
    /// <summary>
    /// 指定提供程序别名：配置时有用
    /// </summary>
    [ProviderAlias("File")]
    public class FileLoggerProvider : ILoggerProvider
    {
        public FileLoggerProvider()
        {

        }
        
        private LoggerExternalScopeProvider ScopeProvider = new LoggerExternalScopeProvider();
        
        public ILogger CreateLogger(string categoryName)
        {
            var logger = new FileLogger(categoryName, ScopeProvider);
            logger.ScopeProvider = new LoggerExternalScopeProvider();
            return logger;
        }

        public void Dispose()
        {
            //用于释放资源
        }
    }
}
